package com.uyii.springbootrabbitmq.controller;

import com.uyii.springbootrabbitmq.producer.RabbitMQProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MessageController {

    @Autowired
    private RabbitMQProducer rabbitMQProducer;

    @PostMapping("/sendMessage")
    public String sendMessage() {
        // 发送100条消息
        for (int i = 0; i < 10; i++) {
            rabbitMQProducer.send("测试 RabbitMQ 消息~~");
        }
        return "Message sent successfully!";
    }
}